{include file="public/toper"/}
<div class="orgWrap x-body">


</div>

<script type="text/javascript">
    //全局定义一次, 加载formSelects
    layui.config({
        base: '/static/js/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        orgChart: 'orgChart'
    });
    //加载模块
    layui.use(['jquery','orgChart'], function() {
        var $ = layui.jquery;
        var orgChart = layui.orgChart;

        $.ajax({
            type: "POST",
            data:{id:{$id}},
            url:  "{:url('User/lower')}",
                success: function(res) {
                console.log(res);
                    var data = res.data;
                    //3表示显示到部门的第3级
                    orgChart.render({
                        elm: '.orgWrap',
                        data: data,
                        drag: true,
                        depth: 3,
                        renderdata: function(data, $dom) {
                            var value = data;
                            if(value && Object.keys(value).length) {
                                var $name = $('<div class="name"></div>');
                                !!(value.name) && $name.text(value.name);
                                $dom.append($name);
                                $dom.addClass('organization');
                            }
                        },
                        callback: function() {}
                    });
                }

        });


    });
</script>
{include file="public/footer"/}